<template>
	<view>
		<block v-if="isload">
			<!-- #ifndef H5 || APP-PLUS -->
			<view class="topsearch flex-y-center">
				<view class="f1 flex-y-center">
					<image class="img" src="/static/img/search_ico.png"></image>
					<input :value="keyword" placeholder="输入用户昵称或订单号搜索" placeholder-style="font-size:24rpx;color:#C2C2C2"
						@confirm="searchConfirm"></input>
				</view>
			</view>
			<!--  #endif -->
			<view class="content" v-if="datalist && datalist.length>0">
				<view class="label">
					<text class="t1">当面付收款记录（共{{count}}条）</text>
				</view>

				<view class="totalitem">
					<view class="item">
						<view>
							今日收款 : ￥{{info.todaymoney || 0}}元
						</view>
						<view>
							今日结算 : ￥{{info.todayselectmoney || 0}}元
						</view>
					</view>
					<view class="item">
						<view>
							昨日收款 : ￥{{info.yesterdaymoney || 0}}元
						</view>
						<view>
							昨日结算 : ￥{{info.yesterdayselectmoney || 0}}元
						</view>
					</view>
					<view class="item">
						<view>
							累积收款 : ￥{{info.allmoney || 0}}元
						</view>
						<view>
							累积结算 : ￥{{info.allselectmoney || 0}}元
						</view>
					</view>
				</view>


				<view v-for="(item, index) in datalist" :key="index" class="item" @tap="goto"
					:data-url="'facepaydetail?id=' + item.id">
					<view class="f1">
						<image class="t1" :src="item.headimg"></image>
						<text class="t2">{{item.nickname}}</text>
					</view>
					<view class="f2">
						<text class="t5">收款金额：￥{{item.paymoney}}元</text>
						<text class="t2">实际结算：￥{{item.realselectmoney || item.paymoney}}元</text>
						<text class="t2">支付时间：{{dateFormat(item.paytime,'Y-m-d H:i')}}</text>
						<text class="t2"><text style="color: #007AFF;">支付方式：{{item.paytype}}</text></text>
						<text class="t2">订单编号：{{item.ordernum}}</text>
					</view>
				</view>
			</view>
			<nodata v-if="nodata"></nodata>
			<nomore v-if="nomore"></nomore>
		</block>
		<loading v-if="loading"></loading>
		<popmsg ref="popmsg"></popmsg>
	</view>
</template>

<script>
	var app = getApp();
	export default {
		data() {
			return {
				opt: {},
				loading: false,
				isload: false,

				keyword: '',
				st: 0,
				count: 0,
				datalist: [],
				pagenum: 1,
				nodata: false,
				nomore: false,
				info: {}
			};
		},

		onLoad: function(opt) {
			this.opt = app.getopts(opt);
			this.getdata();
			this.getmoney()
		},
		onPullDownRefresh: function() {
			this.getdata();
		},
		onReachBottom: function() {
			if (!this.nodata && !this.nomore) {
				this.pagenum = this.pagenum + 1;
				this.getdata(true);
			}
		},
		onNavigationBarSearchInputConfirmed: function(e) {
			this.searchConfirm({
				detail: {
					value: e.text
				}
			});
		},
		methods: {
			getdata: function(loadmore) {
				if (!loadmore) {
					this.pagenum = 1;
					this.datalist = [];
				}
				var that = this;
				var pagenum = that.pagenum;
				var st = that.st;
				var keyword = that.keyword;
				that.nodata = false;
				that.nomore = false;
				that.loading = true;
				app.post('AdminOrder/facepaylog', {
					keyword: keyword,
					pagenum: pagenum
				}, function(res) {
					that.loading = false;
					var data = res.data;
					if (pagenum == 1) {
						that.count = res.count;
						that.datalist = data;
						if (data.length == 0) {
							that.nodata = true;
						}
						that.loaded();
					} else {
						if (data.length == 0) {
							that.nomore = true;
						} else {
							var datalist = that.datalist;
							var newdata = datalist.concat(data);
							that.datalist = newdata;
						}
					}
				});
			},
			getmoney() {
				var that = this;
				app.post('AdminOrder/facepaytotal', {}, function(res) {
					that.info = res.data
				});
			},
			changetab: function(e) {
				var st = e.currentTarget.dataset.st;
				this.st = st;
				uni.pageScrollTo({
					scrollTop: 0,
					duration: 0
				});
				this.getdata();
			},
			searchChange: function(e) {
				this.keyword = e.detail.value;
			},
			searchConfirm: function(e) {
				var that = this;
				var keyword = e.detail.value;
				that.keyword = keyword;
				that.getdata();
			}
		}
	};
</script>
<style>
	@import "../common.css";

	.topsearch {
		width: 94%;
		margin: 16rpx 3%;
	}

	.topsearch .f1 {
		height: 60rpx;
		border-radius: 30rpx;
		border: 0;
		background-color: #fff;
		flex: 1
	}

	.topsearch .f1 .img {
		width: 24rpx;
		height: 24rpx;
		margin-left: 10px
	}

	.topsearch .f1 input {
		height: 100%;
		flex: 1;
		padding: 0 20rpx;
		font-size: 28rpx;
		color: #333;
	}

	.content {
		width: 94%;
		margin: 0 3%;
		background: #fff;
		border-radius: 16rpx
	}

	.content .label {
		display: flex;
		width: 100%;
		padding: 24rpx 16rpx;
		color: #333;
	}

	.content .label .t1 {
		flex: 1
	}

	.content .label .t2 {
		width: 300rpx;
		text-align: right
	}

	.content .item {
		width: 100%;
		padding: 20rpx 20rpx;
		border-top: 1px #f5f5f5 solid;
		display: flex;
		align-items: center
	}

	.content .item .f1 {
		display: flex;
		flex-direction: column;
		margin-right: 20rpx
	}

	.content .item .f1 .t1 {
		width: 100rpx;
		height: 100rpx;
		margin-bottom: 10rpx;
		border-radius: 50%;
		margin-left: 20rpx
	}

	.content .item .f1 .t2 {
		color: #666666;
		text-align: center;
		width: 140rpx;
		display: -webkit-box;
		-webkit-box-orient: vertical;
		-webkit-line-clamp: 1;
		overflow: hidden;
	}

	.content .item .f2 {
		flex: 1;
		width: 200rpx;
		font-size: 30rpx;
		display: flex;
		flex-direction: column
	}

	.content .item .f2 .t1 {
		color: #FD4A46;
		height: 40rpx;
		line-height: 40rpx;
		font-size: 24rpx
	}

	.content .item .f2 .t2 {
		color: #999;
		height: 40rpx;
		line-height: 40rpx;
		font-size: 24rpx
	}

	.content .item .f2 .t5 {
		color: #ff0000;
		height: 40rpx;
		line-height: 40rpx;
		font-size: 26rpx
	}

	.content .item .f2 .t6 {
		color: #999;
		height: 40rpx;
		line-height: 40rpx;
		font-size: 24rpx
	}

	.content .item .f2 .t3 {
		color: #aaa;
		height: 40rpx;
		line-height: 40rpx;
		font-size: 24rpx
	}

	.totalitem .item {
		display: flex;
		justify-items: end;
	}

	.totalitem .item view {
		flex: 1;
		color: #000000;
	}
</style>